import tkinter as tk
from tkinter.ttk import Separator
from gui.config import *


def login_page(master, name, pwd, login_handle):
    titleFrame = tk.Frame(master, bg='Lavender')

    tk.Label(titleFrame, text='xx宾馆', font=('楷体', 40, 'bold italic'), width=7, fg='DeepSkyBlue', bg='Lavender') \
        .pack(side='left', padx=(160, 0), pady=(130, 80))
    tk.Label(titleFrame, text='客房管理系统', bg='Lavender', font=('黑体', 30, 'bold')) \
        .pack(side='left', padx=(10, 0), pady=(130, 80))

    titleFrame.pack(side='top', fill='x')

    # 用户信息
    bg = 'White'
    infoFrame = tk.Frame(master, bg=bg)

    def focus_next(event=None):
        pwdEntry.focus_set()

    # 用户名框架
    usrFrame = tk.Frame(infoFrame, bg=bg)
    tk.Label(usrFrame, text="账户：", bg=bg,
             font=myFont).pack(side='left', padx=(220, 10), pady=(50, 0))
    nameEntry = tk.Entry(usrFrame, show=None, width=25, textvariable=name, bd=0,
             font=myFont)
    nameEntry.bind('<Return>', focus_next)
    nameEntry.pack(side='left', pady=(50, 0))
    usrFrame.pack(side='top', anchor='nw')

    Separator(infoFrame, orient='horizontal').pack(padx=(300, 200), pady=(0, 20), fill='x')

    # 用户密码框架
    pwdFrame = tk.Frame(infoFrame, bg=bg)
    tk.Label(pwdFrame, text="密码：", bg=bg,
             font=myFont).pack(side='left', padx=(220, 10), pady=0)
    pwdEntry = tk.Entry(pwdFrame, show='●', width=25, textvariable=pwd, bd=0,
             font=myFont)
    pwdEntry.bind('<Return>', login_handle)
    pwdEntry.pack(side='left')
    pwdFrame.pack(side='top', anchor='nw')

    Separator(infoFrame, orient='horizontal').pack(padx=(300, 200), pady=(0, 20), fill='x')

    btnFrame = tk.Frame(infoFrame, bg=bg)
    tk.Button(btnFrame, text='登录系统', relief='ridge', activebackground='white', font=myFont, width=31, bg='Teal',
              fg='white', command=login_handle) \
        .pack(side='left', padx=(220, 0), pady=(20, 110))
    btnFrame.pack(side='top', anchor='nw')

    infoFrame.pack(fill='x')



